﻿using System.Collections.Generic;
using System.ServiceModel;
using VMukti.Business.CommonDataContracts;
using VMukti.Business.WCFServices.BootStrapServices.DataContracts;

namespace VMukti.Business.WCFServices.SuperNodeServices.BasicHttp
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
    public class SuperNodeDelegates : IHttpSuperNodeService
    {
        public delegate void DelHttpsvcJoin(string uName, string bindingType);
        public delegate List<string> DelHttpGetBuddies(string uName);
        public delegate void DelHttpAddBuddies(string username, string buddyname, string buddystatus);
		public delegate void DelHttpRemoveBuddies(string username, string buddyname);
        public delegate void DelHTTPAddNodeBuddies(string username, List<string> NodeBuddies);
        
        public delegate void DelHttpsvcUnjoin(string uName);
        public delegate List<string> DelHttpsvcGetBuddyStatus(List<string> BuddyList);
        public delegate bool DelIsSuperNodeAvailable();
        public delegate List<clsMessage> DelsvcGetSpecialMsgs(string uName);
        public delegate void DelsvcSetSpecialMsgs(string from, string to, string msg, clsModuleInfo objModInfo);
        //public delegate void DelsvcPageSetSpecialMsgs(string from, string to, string msg, List<clsModuleInfo> objModInfo);
        public delegate void DelsvcPageSetSpecialMsgs(string from, string to, string msg, clsPageInfo objPageInfo);
        public delegate string[] DelsvcStartAService(VMuktiAPI.PeerType PeerType, string ModuleName);
        public delegate string[] DelIsAutherizedUser(clsBootStrapInfo objBootStrapInfo, string strUserName, string strPassword);
        public delegate string DelIsAutherized(string strUserName);
        public delegate string DelsvcAddSIPUser();
        public delegate void DelsvcRemoveSIPUser(string strSIPNumber);
        public delegate string DelsvcGetConferenceNumber();
        public delegate void DelsvcSetRemoveDraggedBuddy(string from, List<string> to, string msg, clsModuleInfo objModInfo);
        public delegate void DelsvcAddDraggedBuddy(string from, string to, string msg, clsModuleInfo objModInfo);
        public delegate void DelsvcAddPageDraggedBuddy(string from, string to, string msg, List<clsModuleInfo> objModInfo);

        public delegate void DelsvcGetNodeNameByIP(string NodeName, string NodeIP);

        public event DelHttpsvcJoin EntHttpsvcjoin;
        public event DelHttpGetBuddies EntHttpGetBuddies;
        public event DelHttpAddBuddies EntHttpAddBuddies;
		public event DelHttpRemoveBuddies EntHttpRemoveBuddies;
        public event DelHTTPAddNodeBuddies EntHTTPAddNodeBuddies;
        
        public event DelHttpsvcUnjoin EntHttpsvcUnjoin;
        public event DelHttpsvcGetBuddyStatus EntHttpsvcGetBuddyStatus;
        public event DelIsSuperNodeAvailable EntIsSuperNodeAvailable;
        public event DelsvcGetSpecialMsgs EntsvcGetSpecialMsgs;
        public event DelsvcSetSpecialMsgs EntsvcSetSpecialMsg;
        public event DelsvcPageSetSpecialMsgs EntsvcPageSetSpecialMsg;
        public event DelsvcStartAService EntsvcStartAService;
        public event DelIsAutherizedUser EntIsAutherizedUser;
        public event DelIsAutherized EntIsAutherized;
        public event DelsvcAddSIPUser EntsvcAddSIPUser;
        public event DelsvcRemoveSIPUser EntsvcRemoveSIPUser;
        public event DelsvcGetConferenceNumber EntsvcGetConferenceNumber;
        public event DelsvcSetRemoveDraggedBuddy EntsvcSetRemoveDraggedBuddy;
        public event DelsvcAddDraggedBuddy EntsvcAddDraggedBuddy;
        public event DelsvcAddPageDraggedBuddy EntsvcAddPageDraggedBuddy;

        public event DelsvcGetNodeNameByIP EntsvcGetNodeNameByIP;

		#region IHttpSuperNodeService Members
		
        public void svcJoin(string uName, string bindingType)
        {
            if (EntHttpsvcjoin != null)
            {
                EntHttpsvcjoin(uName, bindingType);
            }
        }

        public List<string> GetBuddies(string uName)
        {
            if (EntHttpGetBuddies != null)
            {
                return EntHttpGetBuddies(uName);
            }
            else
            {
                return null;
            }
        }

        public void AddBuddies(string username, string buddyname, string buddystatus)
        {
            if (EntHttpAddBuddies != null)
            { EntHttpAddBuddies(username, buddyname, buddystatus); }
        }

        public void svcUnjoin(string uName)
        {
            if (EntHttpsvcUnjoin != null)
            {
                EntHttpsvcUnjoin(uName);
            }
        }

        public List<string> GetBuddyStatus(List<string> Buddyname)
        {
            if (EntHttpsvcGetBuddyStatus != null)
            {
                return EntHttpsvcGetBuddyStatus(Buddyname);
            }
            else
            {
                return null;
            }
        }

        public bool IsSuperNodeAvailable()
        {
            if (EntIsSuperNodeAvailable != null)
            {
                return EntIsSuperNodeAvailable();
            }
            else
            {
                return false;
            }
        }

        public List<clsMessage> svcGetSpecialMsgs(string uName)
        {
            if (EntsvcGetSpecialMsgs != null)
            {
                return EntsvcGetSpecialMsgs(uName);
            }
            else
            {
                return null;
            }
        }

        public void svcSetSpecialMsgs(string from, string to, string msg, clsModuleInfo objModInfo)
        {
            if (EntsvcSetSpecialMsg != null)
            {
                EntsvcSetSpecialMsg(from, to, msg, objModInfo);
            }
        }

        public string[] svcStartAService(VMuktiAPI.PeerType PeerType, string ModuleName)
        {
            if (EntsvcStartAService != null)
            {
                return EntsvcStartAService(PeerType, ModuleName);
            }
            else
            {
                return null;
            }
        }

        public string[] IsAuthorizedUser(clsBootStrapInfo objBootStrapInfo, string strUserName, string strPassword)
        {
            if (EntIsAutherizedUser != null)
            {
                return EntIsAutherizedUser(objBootStrapInfo, strUserName, strPassword);
            }
            else
            {
                return null;
            }
        }

        public string IsAuthorized(string strUserName)
        {
            if (EntIsAutherized != null)
            {
                return EntIsAutherized(strUserName);
            }
            else
            {
                return null;
            }
        }

        public string svcAddSIPUser()
        {
            if (EntsvcAddSIPUser != null)
            {
                return EntsvcAddSIPUser();
            }
            else
            {
                return null;
            }
        }

        public void svcRemoveSIPUser(string strSIPNumber)
        {
            if (EntsvcRemoveSIPUser != null)
            {
                EntsvcRemoveSIPUser(strSIPNumber);
            }
        }

        public string svcGetConferenceNumber()
        {
            if (EntsvcGetConferenceNumber != null)
            {
                return EntsvcGetConferenceNumber();
            }
            else
            {
                return null;
            }
        }

        public void svcSetSpecialMsgs(string from, string to, string msg, clsPageInfo objPageInfo)
        {
            if (EntsvcPageSetSpecialMsg != null)
            {
                EntsvcPageSetSpecialMsg(from, to, msg, objPageInfo);
            }
        }

        public void svcAddDraggedBuddy(string from, string to, string msg, clsModuleInfo objModInfo)
        {
            if (EntsvcAddDraggedBuddy != null)
            {
                EntsvcAddDraggedBuddy(from, to, msg, objModInfo);
            }
        }

        public void svcAddDraggedBuddy(string from, string to, string msg, List<clsModuleInfo> lstModInfo)
        {
            if (EntsvcAddPageDraggedBuddy != null)
            {
                EntsvcAddPageDraggedBuddy(from, to, msg, lstModInfo);
            }
        }

        public void svcSetRemoveDraggedBuddy(string from, List<string> to, string msg, clsModuleInfo objModInfo)
        {
            if (EntsvcSetRemoveDraggedBuddy != null)
            {
                EntsvcSetRemoveDraggedBuddy(from, to, msg, objModInfo);
            }
        }

		public void RemoveBuddies(string username, string buddyname)
		{
			if (EntHttpRemoveBuddies != null)
			{
				EntHttpRemoveBuddies(username, buddyname);
			}
		}

        public void AddNodeBuddies(string username, List<string> NodeBuddies)
        {
            if (EntHTTPAddNodeBuddies != null)
            {
                EntHTTPAddNodeBuddies(username, NodeBuddies);
            }
        }

        public void svcGetNodeNameByIP(string NodeName, string NodeIP)
        {
            if (EntsvcGetNodeNameByIP != null)
            {
                EntsvcGetNodeNameByIP(NodeName,NodeIP);
            }
            
        }
		#endregion
    }
}
